package com.cold.demo.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: zyc
 */
@Controller
public class ThymeleafController {

    @GetMapping("/thymeleaf/test")
    public String test(Model model) {
        Map<String, Object> data = new HashMap<>();
        data.put("msg", "周银昌");
        data.put("link", "http://www.baidu.com");
        model.addAllAttributes(data);
        return "test";
    }


    @GetMapping("/thymeleaf/test2")
    public String test2(ModelAndView modelAndView) {
        Map<String, Object> data = new HashMap<>();
        data.put("msg", "周银昌2");
        data.put("link", "http://www.baidu.com");
        modelAndView.addAllObjects(data);
        return "test";
    }
}
